#ifndef SKYROAD_LOGGER_H_
#define SKYROAD_LOGGER_H_

#include <skyroad/detail/config.hpp>
#include <skyroad/log/rolling_file.hpp>

inline char const* time_now_string()
{
	time_t t = std::time(0);
	tm* timeinfo = std::localtime(&t);
	static char str[200];
	std::strftime(str, 200, "%b %d %X", timeinfo);
	return str;
}

SKYROAD_DECL int g_log_level();
SKYROAD_DECL rolling_file& g_log_dbg();
SKYROAD_DECL rolling_file& g_log_inf();
SKYROAD_DECL rolling_file& g_log_wrn();
SKYROAD_DECL rolling_file& g_log_err();
SKYROAD_DECL rolling_file& g_log_ftl();

enum log_level 
{
    disable_all = (unsigned int)-1,
    enable_all = 0,
    debug = 1000,
    info = 2000,
    warning = 3000,
    error = 4000,
    fatal = 5000
};

// #define USE_LOG_IF_LEVEL(l, is_enabled) if ( !(is_enabled) ) ; else  l
// 
// #define LDEBUG_		USE_LOG_IF_LEVEL(g_log_dbg() << "\r\n" << time_now_string() << "[" << __FILE__ << "][" << __FUNCTION__ << "][" << __LINE__ << "]" , g_log_level() <= debug)
// #define LINFO_		USE_LOG_IF_LEVEL(g_log_inf() << "\r\n" << time_now_string() , g_log_level() <= info)
// #define LWARNING_	USE_LOG_IF_LEVEL(g_log_wrn() << "\r\n" << time_now_string(), g_log_level() <= warning)
// #define LERROR_		USE_LOG_IF_LEVEL(g_log_err() << "\r\n" << time_now_string(), g_log_level() <= error)
// #define LFATAL_		USE_LOG_IF_LEVEL(g_log_ftl() << "\r\n" << time_now_string(), g_log_level() <= fatal)

void init_logs();

#endif